$(function() {
// 获取用户评价的列表
  var index = $(".load-more").attr("data-id");
  if (index == "1") {index = ""};
  get_evaluate();
  function get_evaluate(){
    var evaluate_type = $(".evaluate-but a.cua").attr("data-id");
    if (evaluate_type=="all") {
      var evaluate_url = apitest+"/evaluate?type="+evaluate_type;
    }else{
      var evaluate_url = apitest+"/evaluate?type=score&score="+evaluate_type;
    }
    var loading = '<div class="loading" style="margin-top:20px">加载中...</div>';
    $(".good-evaluate").append(loading);
    $.get(evaluate_url, function(data){
      }, "json").error(function(data) {
        var status_code = $.parseJSON(data.responseText);
        layer.msg(status_code.message);
      }).success(function(data) {
        var extras = data.data.extras;
        $(".loading").remove();
        $(".high").text(extras.high);
        $(".intermediate").text(extras.intermediate);
        $(".low").text(extras.low);
        $(".all-e").text(extras.total_count);
         var obj = data.data.list;
         console.info(obj);
         var src = '';
         if (obj.length>7) {
            $(".load-more").css("display","block")
          }else{
            $(".load-more").css("display","none")
          }
        if (obj.length>0) {
           for(var i = 0;i < obj.length; i++){
            var tags_length = obj[i].tags.length;
            if (obj[i].realname==null) {obj[i].realname="普通用户"};
            src +='<li>'
                 src +='<div class="fl box1 font16">'
                   src +='<p class="colorD"><span>'+obj[i].realname+'</span>&nbsp;&nbsp;&nbsp;&nbsp;<span>'+obj[i].difference_date+'</span></p>'
                   src +='<br>'
                   src +='<p class="font18 colorE" style="line-height: 30px">'+obj[i].comment+'</p>'
                   src +='<p class="evaluate-type">'
                    for (var n = 0; n < tags_length; n++) {
                      if (obj[i].tags[n]==null) {
                       src +=''
                      }else{
                        src +='<a>'+obj[i].tags[n]+'</a>'
                      }
                    } 
                   src +='</p>'
                 src +='</div>'
                 src +='<div class="fl box2 font18"><span class="colorB">'+obj[i].score+'</span> 分</div>'
                 src +='<div class="fl box3">'
                   src +='<a href="'+jumpUrl+'/lawyer/'+obj[i].lawyer_user_id+'"><img class="lvimg" src="'+obj[i].lawyer_avatar+'" width="80" height="80"></a>'
                  src +=' <p style="line-height:50px;"><a class="font18 colorA" href="'+jumpUrl+'lawyer/'+obj[i].lawyer_user_id+'">'+obj[i].lawyer_realname+'</a></p>'
                 src +='</div>'
               src +='</li>'
            }
        }else{
          var src ='<li class="textac"><span class="noData2"></span></li>';
        }
        $(".good-evaluate").append(src);
      });
    }

   // 加载更多
    $(document).on("click",".load-more",function(e){
      index = parseInt($(".load-more").attr("data-id"))+1;
      $(".load-more").attr("data-id",index);
      get_evaluate();
    });

  // 点击切换服务介绍
  $(".introduce li").click(function(){
    $(".introduce li").removeClass("cu");
    $(this).addClass("cu");
  });

  // 点击切换评价列表
  $(".evaluate-but a").click(function(){
    $(".evaluate-but a").removeClass("cua");
    $(".good-evaluate li").remove();
    $(this).addClass("cua");
    var evaluate_type =  $(this).attr("data-id");
    var evaluate_url = jumpUrl+'/lawyer/workscopes?'+evaluate_type;
    get_evaluate();
  });
  
  

});



